import {defineStore} from 'pinia'

interface LocalState {
    collapse: boolean
}

export const useLocalStore = defineStore('localStore', {
    state: (): LocalState => ({
        collapse: false
    }),
    actions: {
        setCollapse(_collapse: boolean) {
            this.collapse = _collapse
        }
    },
    // 使用该插件，开启数据缓存
    persist: {
        enabled: true,
        strategies: [
            {storage: sessionStorage, paths: []}, // firstName 和 lastName字段用sessionStorage存储
            {storage: localStorage, paths: ['collapse']}, // accessToken字段用 localstorage存储
        ],
    },
})